home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog Special Freeware 31
/
FreelogHS31.iso
/
ArgentCompta
/
Bankperfect
/
bp.exe
/
Scripts
/
Export XML
/
export_xml.py
< prev
Wrap
Text File
|
2007-03-18
|
2KB
|
45 lines
import BP
CtgNames = {}
for i, c in enumerate(BP.CategName):
p = c.find("=")
Idx = int(c[:p])
c = c[p+1:].strip()
Parent = BP.CategName[BP.CategParent[i]]
p = Parent.find("=")
PIdx = int(Parent[:p])
if Idx == PIdx: CtgNames[Idx] = c
else: CtgNames[Idx] = "%s:%s" %(Parent[p+1:].strip(), c)
def enc(s):
res = ""
for c in s:
if c.isalnum() or c in " $/%=*.@;:,_-()[]\\": res += c
elif c == "Ç": res += "€"
else: res += '%d;' %ord(c)
return res
acc = ' <compte nom="%s" num="%s" adresse_agence="%s" nom_agence="%s" num_agence="%s" nom_banque="%s" num_banque="%s" bic="%s" monnaie1="%s" monnaie2="%s" taux1="%s" taux2="%s" iban="%s" virtuel="%s">'
opr = ' <operation date="%s" mode="%s" tiers="%s" info="%s" categ="%s" montant="%s" pointage="%s" />'
s = ['<?xml version="1.0" encoding="UTF-8" ?>', '<comptes>']
for i in range(BP.AccountCount()):
b, a = BP.AccountBranchNumber[i].split(" ")
c1, r1 = BP.AccountCurrency1[i].split("|")
c2, r2 = BP.AccountCurrency2[i].split("|")
v = BP.AccountName[i], BP.AccountNumber[i], BP.AccountBranchAddress[i], BP.AccountBranchName[i], a, BP.AccountBankName[i], b, BP.AccountBIC[i], c1, c2, r1, r2, BP.AccountIBAN[i], str(BP.AccountIsVirtual[i])
s.append(acc %tuple(map(enc, v)))
for j in range(BP.OperationCount[i]):
ctg = BP.OperationCateg[i][j]
if ctg == -1: ctg = "Aucune"
else: ctg = CtgNames[ctg]
v = BP.OperationDate[i][j], BP.OperationMode[i][j], BP.Operationthirdparty[i][j], BP.OperationDetails[i][j], ctg, str(BP.OperationAmount[i][j]), str(BP.OperationMark[i][j])
s.append(opr %tuple(map(enc, v)))
s.append(" </compte>")
s.append("</comptes>")
p = BP.BankPerfectFileName()
p = "%s_export.xml" %p[:p.rfind(".")]
open(p, "w").write("\n".join(s))
if BP.MsgBox("Le fichier %s a ΘtΘ crΘΘ.\nSouhaitez-vous l'ouvrir ?" %p, 68) == 6:
BP.ShellExecute("open", p, "", 1)